<?php
require_once("main.php");

mysql_connect($host, $user,$passwd) or die("erreur de connexion au serveur");
mysql_select_db($bdd) or die("erreur de connexion a la base de donnees");

if(isTokenExist()){
	$query = "SELECT fieldValue FROM ExtensionData where userId='".getToken()
	."' and extensionId='".getExtension()."' and fieldName='timestamp'";
	$sql_result = mysql_query($query);
	$i = 0;
	if($sql_result){
		if($row = mysql_fetch_row($sql_result)){
			$result['timestamp'] = $row[0];
		} else {
			$result['timestamp'] = "";
		}
	} else {
		$result['timestamp'] = "";
	}
} else {
	$result['timestamp'] = "";
	$result['error'] = "Authentication error";
}

echo json_encode($result);
mysql_close();
?>